#include<iostream>
using namespace std;



bool binary_search(int arr[] ,int n,int target)
{
  int k=0;
  int l=0;
  int r=n;
  int mid;
  while (r>l)
  {
      mid = (r+l)/2;
      k++;

      if(arr[mid]>target)
          r=mid;
      else
      {
          if(( mid < r-1) & (arr[mid+1]<=target))
          {
              l=mid+1;
          }
          else
          {
              cout<<"查询次数： "<<k<<endl;
              cout<<"位数： "<<mid<<endl;
              return true;
          }

      }

  }
  return false;
}

int main()
{
    int a[13]={1,2,2,3,3,3,3,3,4,5,7,7,8};
    int n=13;
    int target;
    bool flag;
    for(int i=0;i<n;i++)
    {
        cout<<a[i]<<' ';

    }
    cout<<endl;

    cin >> target;
    flag = binary_search(a,n,target);
    cout<< flag<<endl;
    return 0;
}


